package com.acwing.partition12;

import java.io.*;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;

/**
 * @author `RKC`
 * @date 2022/2/10 10:10
 */
public class AC1191家谱树 {

    private static final int N = 110, M = N * N / 2;
    private static int[] head = new int[N], ver = new int[M], next = new int[M], din = new int[N];
    private static Queue<Integer> q = new ArrayDeque<>(N);

    private static int n = 0, m = 0, idx = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = Integer.parseInt(reader.readLine());
        Arrays.fill(head, -1);
        for (int i = 1; i <= n; i++) {
            String[] ss = reader.readLine().split(" ");
            for (int j = 0; j < ss.length - 1; j++) {
                int v = Integer.parseInt(ss[j]);
                add(i, v);
                din[v]++;
            }
        }
        topsort();
        writer.flush();
    }

    private static void topsort() throws IOException {
        for (int i = 1; i <= n; i++) {
            if (din[i] == 0) q.add(i);
        }
        while (!q.isEmpty()) {
            int u = q.poll();
            writer.write(u + " ");
            for (int i = head[u]; i != -1; i = next[i]) {
                int v = ver[i];
                din[v]--;
                if (din[v] == 0) q.add(v);
            }
        }
    }

    private static void add(int a, int b) {
        ver[idx] = b;
        next[idx] = head[a];
        head[a] = idx++;
    }
}
